//
//  AppDefine.h
//  PeiJue
//
//  Created by 李西亚 on 2017/9/20.
//  Copyright © 2017年 lixiya. All rights reserved.
//

#ifndef AppDefine_h
#define AppDefine_h


/** 屏幕宽高 */
#define kIphoneWidth  [UIScreen mainScreen].bounds.size.width
#define kIphoneHeight [UIScreen mainScreen].bounds.size.height

#define kIosVersion ([[[UIDevice currentDevice] systemVersion] doubleValue])
#define ios7x ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) && ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0f)
#define ios8x ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0f) && ([[[UIDevice currentDevice] systemVersion] floatValue] < 9.0f)
#define ios9x ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0f) && ([[[UIDevice currentDevice] systemVersion] floatValue] < 10.0f)
#define ios10x ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0f) && ([[[UIDevice currentDevice] systemVersion] floatValue] < 11.0f)
#define ios11x [[[UIDevice currentDevice] systemVersion] floatValue] >=11.0f


#define iphone4x_3_5 ([UIScreen mainScreen].bounds.size.height==480.0f)
#define iphone5x_4_0 ([UIScreen mainScreen].bounds.size.height==568.0f)
#define iphone678_4_7 ([UIScreen mainScreen].bounds.size.height==667.0f)
#define iphone678Plus_5_5 ([UIScreen mainScreen].bounds.size.height==736.0f || [UIScreen mainScreen].bounds.size.height==414.0f)
#define iphoneX ([UIScreen mainScreen].bounds.size.height==812.0f)


/** tabbar、导航条、状态栏高度 */
#define KTabBarHeight  (iphoneX ? 83 : 49)
#define KNavBarHeight  (iphoneX ? 88 : 64)
#define KStatusBarHeight  [[UIApplication sharedApplication] statusBarFrame].size.height


/** 常用对象 */
#define kAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
#define kNotifCenter [NSNotificationCenter defaultCenter]
#define kKeyWindow [UIApplication sharedApplication].keyWindow

//app名称
#define kAppName [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
//app版本
#define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]


/** 字符串是否为空 */
#ifndef isNULLString

#define isNULLString(__string__) \
(__string__==nil || \
![__string__ isKindOfClass:[NSString class]] || \
[__string__ isEqualToString:@""] || \
[__string__ isEqualToString:@"<null>"] || \
[__string__ isEqualToString:@"null"] || \
[__string__ isEqualToString:@"(null)"] || \
[__string__ isKindOfClass:[NSNull class]] || \
[[__string__ stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)

#endif

/** 字典比较 */
#ifndef isDictWithCountMoreThan0

#define isDictWithCountMoreThan0(__dict__) \
(__dict__!=nil && \
[__dict__ isKindOfClass:[NSDictionary class] ] && \
__dict__.count>0)

#endif

/** 数组比较 */
#ifndef isArrayWithCountMoreThan0

#define isArrayWithCountMoreThan0(__array__) \
(__array__!=nil && \
[__array__ isKindOfClass:[NSArray class] ] && \
__array__.count>0)

#endif


/** 路径 */
//获取沙盒Document路径
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒temp路径
#define kTempPath NSTemporaryDirectory()
//获取沙盒Cache路径
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]


/** DEBUG */
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define NSLog(...)
#define debugMethod()
#endif

#endif /* AppDefine_h */
